      SUBROUTINE CONCATI5(line1, i)
      IMPLICIT NONE
      CHARACTER*(*) line1
      INTEGER i

      If (i .LT. 10000) Then
        CALL CONCATI(line1, 0)
        If (i .LT. 1000) Then
          CALL CONCATI(line1, 0)
          If (i .LT. 100) Then
            CALL CONCATI(line1, 0)
            If (i .LT. 10) Then
              CALL CONCATI(line1, 0)
            Endif
          Endif
        Endif
      Endif
      CALL CONCATI(line1, i)

      RETURN
      END

c---------------------------------------------------------------
      SUBROUTINE CONCATI(line1, i)
      IMPLICIT NONE
      CHARACTER*(*) line1
      INTEGER i
      INTEGER lbeg1, lend1, lbeg2, lend2
      CHARACTER*(18) line2

      line2 = '                '
      WRITE(line2, '(i7)') i
      CALL CLIP(line1, lbeg1, lend1)
      CALL CLIP(line2, lbeg2, lend2)

      line1(lend1+1:lend1+1+lend2-lbeg2) = line2(lbeg2:lend2)
      RETURN
      END

c---------------------------------------------------------------

      SUBROUTINE CLIP(line, l1, l2)
      INTEGER l1, l2
      CHARACTER*(*) line
      CALL LEAD(line,l1)
      CALL TRAIL(line,l2)
      RETURN
      END
c---------------------------------------------------------------
      SUBROUTINE LEAD(line, lenc)
      IMPLICIT NONE
      INTEGER lenc
      CHARACTER*(*) line
      INTEGER lgth, i
      lgth = len(line)
      lenc = 1
      DO 10 i = 1, lgth
        IF (line(i:i).ne.' ') THEN
          lenc = i
          GOTO 20
        ENDIF
   10 CONTINUE
   20 CONTINUE
      RETURN
      END
c---------------------------------------------------------------

      SUBROUTINE TRAIL(line, lenc)
      IMPLICIT NONE
      INTEGER lenc
      CHARACTER*(*) line
      INTEGER lgth, i
      lgth = len(line)

      DO 110 i = lgth, 1, -1
        IF (line(i:i).ne.' ') THEN
          lenc = i
          GOTO 120
        ENDIF
  110 CONTINUE
  120 CONTINUE
      RETURN
      END
